﻿namespace Genesis.Domain
{

    using Genesis.Infrastructure;
    using Genesis.Infrastructure.Domain;

    public class Code : Entity
    {

        [Signature]
        public virtual string Name { get; protected set; }

        public virtual string Usage { get; set; }

        public virtual string Search { get; protected set; }

        public virtual string Replace { get; protected set; }

        public virtual void SetName(string name)
        {

            Logic.Check(!string.IsNullOrEmpty(name) && !string.IsNullOrWhiteSpace(name), "Name can not be null, empty or whitespace!");
            
            Name = name.Trim();
        
        }

        public virtual void SetSearch(string search)
        {
        
            Logic.Check(!string.IsNullOrEmpty(search) && !string.IsNullOrWhiteSpace(search), "Search can not be null, empty or whitespace!");
            
            Search = search.Trim();
        
        }

        public virtual void SetReplace(string replace)
        {
        
            Logic.Check(!string.IsNullOrEmpty(replace) && !string.IsNullOrWhiteSpace(replace), "Replace can not be null, empty or whitespace!");
            
            Replace = replace.Trim();
        
        }

        public Code(string name)
        {
        
            SetName(name);
        
        }

        protected Code() { }

    }

}